home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
language
/
xlisp_21.zoo
/
xlisp.mac
< prev
next >
Wrap
Internet Message Format
|
1990-02-28
|
27KB
From sce!mitel!uunet!datapg!com50!pai!erc Tue Nov 14 08:51:33 EST 1989
Article: 753 of comp.lang.scheme
Path: cognos!sce!mitel!uunet!datapg!com50!pai!erc
From: erc@pai.UUCP (Eric Johnson)
Newsgroups: comp.lang.scheme,comp.sys.mac
Subject: Re: How to build xscheme for the mac
Summary: Hope this helps...
Keywords: xscheme, mac
Message-ID: <742@pai.UUCP>
Date: 11 Nov 89 18:55:05 GMT
References: <2091@cunixc.cc.columbia.edu>
Organization: Prime Automation, Inc., Burnsville, MN
Lines: 1374
Xref: cognos comp.lang.scheme:753 comp.sys.mac:33459
In article <2091@cunixc.cc.columbia.edu>, puglia@cunixc.cc.columbia.edu (Paul Puglia) writes:
> How does you build xscheme on a macintosh ? I have a copy of
> the xscheme sources compiles fine on a unix machine, and works
> great on a pc with turbo c. When I tried to compile it on a
> friends mac II using his copy of lightspeed c. I have no luck.
> Could someone please describe the procedure to compile this program, and
> comment on if anything else is need to compile xscheme. I know that you
> need some resource to compile xlisp on a mac. Do you need the same sort of
> stuff for xscheme
> Thanks in advance
> Paul Puglia
> Dept of Civil Engineering
> Columbia University
Porting Xlisp/XScheme:
Awhile back, while I was taking an AI course, I was spending a lot of time
trekking to campus and using their LISP system. To avoid travel time (and
to work on LISP at any hour I wanted), I got into porting XLisp. In looking at
the code, I'd say XLisp and XScheme are two of the most portable C programs
I have ever seen. Now, I've spent most of my time on XLisp, so your
mileage may vary, but...
XLisp seems to place most Operating System (OS)-dependent features in
separate files, named dosstuff.c, osptrs.h, osdefs.h. On UNIX, the "stuff:
file is called unixstuf.c and on the Mac its called macstuff.c (all file
names are <= 8 chars for MS-DOS). The mac version also has a resource
compiler file (that is, a file you run through the resource compiler to
generate a resource file).
I assume (hope) XScheme is similiar. Below, I placed all my Mac-related
files from XLisp (2.0, I think). The XScheme stuff should be similiar.
I hope these help. (Note: I don't have the full sources around now, just
the Mac and UNIX-specific files.) (Note2: Two extra files, macfun.c and
macinit.c are below, its been so long that I'm not sure if these are extras
or necessary--Sorry.)
I'm placing these files here in hopes they can help you with your porting. I
do know that binary executable versions of XScheme are available on the
BIX bulletin board (Byte magazine Information eXchange)--see Byte mag
for details. Getting the binaries would solve all the Mac porting
problems in one fell swoop.
Anyway, hope this helps,
-Eric
======================== macfun.c =============================================
/* macfun.c - macintosh user interface functions for xlisp */
#include <Quickdraw.h>
#include <WindowMgr.h>
#include <MemoryMgr.h>
#include "xlisp.h"
/* external variables */
extern GrafPtr cwindow,gwindow;
/* forward declarations */
FORWARD LVAL do_0();
FORWARD LVAL do_1();
FORWARD LVAL do_2();
/* xptsize - set the command window point size */
LVAL xptsize()
{
LVAL val;
val = xlgafixnum();
xllastarg();
TextSize((int)getfixnum(val));
InvalRect(&cwindow->portRect);
SetupScreen();
return (NIL);
}
/* xhidepen - hide the pen */
LVAL xhidepen()
{
return (do_0('H'));
}
/* xshowpen - show the pen */
LVAL xshowpen()
{
return (do_0('S'));
}
/* xgetpen - get the pen position */
LVAL xgetpen()
{
LVAL val;
Point p;
xllastarg();
SetPort(gwindow);
GetPen(&p);
SetPort(cwindow);
xlsave1(val);
val = consa(NIL);
rplaca(val,cvfixnum((FIXTYPE)p.h));
rplacd(val,cvfixnum((FIXTYPE)p.v));
xlpop();
return (val);
}
/* xpenmode - set the pen mode */
LVAL xpenmode()
{
return (do_1('M'));
}
/* xpensize - set the pen size */
LVAL xpensize()
{
return (do_2('S'));
}
/* xpenpat - set the pen pattern */
LVAL xpenpat()
{
LVAL plist;
char pat[8],i;
plist = xlgalist();
xllastarg();
for (i = 0; i < 8 && consp(plist); ++i, plist = cdr(plist))
if (fixp(car(plist)))
pat[i] = getfixnum(car(plist));
SetPort(gwindow);
PenPat(pat);
SetPort(cwindow);
return (NIL);
}
/* xpennormal - set the pen to normal */
LVAL xpennormal()
{
xllastarg();
SetPort(gwindow);
PenNormal();
SetPort(cwindow);
return (NIL);
}
/* xmoveto - Move to a screen location */
LVAL xmoveto()
{
return (do_2('m'));
}
/* xmove - Move in a specified direction */
LVAL xmove()
{
return (do_2('M'));
}
/* xlineto - draw a Line to a screen location */
LVAL xlineto()
{
return (do_2('l'));
}
/* xline - draw a Line in a specified direction */
LVAL xline()
{
return (do_2('L'));
}
/* xshowgraphics - show the graphics window */
LVAL xshowgraphics()
{
xllastarg();
scrsplit(1);
return (NIL);
}
/* xhidegraphics - hide the graphics window */
LVAL xhidegraphics()
{
xllastarg();
scrsplit(0);
return (NIL);
}
/* xcleargraphics - clear the graphics window */
LVAL xcleargraphics()
{
xllastarg();
SetPort(gwindow);
EraseRect(&gwindow->portRect);
SetPort(cwindow);
return (NIL);
}
/* do_0 - Handle commands that require no arguments */
LOCAL LVAL do_0(fcn)
int fcn;
{
xllastarg();
SetPort(gwindow);
switch (fcn) {
case 'H': HidePen(); break;
case 'S': ShowPen(); break;
}
SetPort(cwindow);
return (NIL);
}
/* do_1 - Handle commands that require one integer argument */
LOCAL LVAL do_1(fcn)
int fcn;
{
int x;
x = getnumber();
xllastarg();
SetPort(gwindow);
switch (fcn) {
case 'M': PenMode(x); break;
}
SetPort(cwindow);
return (NIL);
}
/* do_2 - Handle commands that require two integer arguments */
LOCAL LVAL do_2(fcn)
int fcn;
{
int h,v;
h = getnumber();
v = getnumber();
xllastarg();
SetPort(gwindow);
switch (fcn) {
case 'l': LineTo(h,v); break;
case 'L': Line(h,v); break;
case 'm': MoveTo(h,v); break;
case 'M': Move(h,v); break;
case 'S': PenSize(h,v);break;
}
SetPort(cwindow);
return (NIL);
}
/* getnumber - get an integer parameter */
LOCAL int getnumber()
{
LVAL num;
num = xlgafixnum();
return ((int)getfixnum(num));
}
/* xtool - call the toolbox */
LVAL xtool()
{
LVAL val;
int trap;
trap = getnumber();
/*
asm {
move.l args(A6),D0
beq L2
L1: move.l D0,A0
move.l 2(A0),A1
move.w 4(A1),-(A7)
move.l 6(A0),D0
bne L1
L2: lea L3,A0
move.w trap(A6),(A0)
L3: dc.w 0xA000
clr.l val(A6)
}
*/
return (val);
}
/* xtool16 - call the toolbox with a 16 bit result */
LVAL xtool16()
{
int trap,val;
trap = getnumber();
/*
asm {
clr.w -(A7)
move.l args(A6),D0
beq L2
L1: move.l D0,A0
move.l 2(A0),A1
move.w 4(A1),-(A7)
move.l 6(A0),D0
bne L1
L2: lea L3,A0
move.w trap(A6),(A0)
L3: dc.w 0xA000
move.w (A7)+,val(A6)
}
*/
return (cvfixnum((FIXTYPE)val));
}
/* xtool32 - call the toolbox with a 32 bit result */
LVAL xtool32()
{
int trap;
long val;
trap = getnumber();
/*
asm {
clr.l -(A7)
move.l args(A6),D0
beq L2
L1: move.l D0,A0
move.l 2(A0),A1
move.w 4(A1),-(A7)
move.l 6(A0),D0
bne L1
L2: lea L3,A0
move.w trap(A6),(A0)
L3: dc.w 0xA000
move.l (A7)+,val(A6)
}
*/
return (cvfixnum((FIXTYPE)val));
}
/* xnewhandle - allocate a new handle */
LVAL xnewhandle()
{
LVAL num;
long size;
num = xlgafixnum(); size = getfixnum(num);
xllastarg();
return (cvfixnum((FIXTYPE)NewHandle(size)));
}
/* xnewptr - allocate memory */
LVAL xnewptr()
{
LVAL num;
long size;
num = xlgafixnum(); size = getfixnum(num);
xllastarg();
return (cvfixnum((FIXTYPE)NewPtr(size)));
}
/* xhiword - return the high order 16 bits of an integer */
LVAL xhiword()
{
unsigned int val;
val = (unsigned int)(getnumber() >> 16);
xllastarg();
return (cvfixnum((FIXTYPE)val));
}
/* xloword - return the low order 16 bits of an integer */
LVAL xloword()
{
unsigned int val;